﻿//////////////////////////////////分地区////////////////////////////////////////
function getrequest(){ 
    var locurl=window.location.href; 
    var start=locurl.indexOf("?"); 
    var end=locurl.length; 
    if(start!=-1){ 
    var tempstr=locurl.substring(start+1,end) 
    tempstr=tempstr.split("&"); 
    var temp; 
    for(var i=0;i<tempstr.length;i++){ 
    temp=tempstr[i].split("="); 
    request[i]=temp; 
    } 
    } 
}
function getCookie(objName)
{//获取指定名称的cookie的值

    var arrStr = document.cookie.split("; ");
	for(var i = 0;i < arrStr.length;i ++){
	var temp = arrStr[i].split("=");
	if(temp[0] == objName) return unescape(temp[1]);
	} 
}	
var display=getCookie("bjip");
if(display!="no" && display!="yes")
{    
    display = "no";
}
var request=new Array(); 
var flag="f";
var ip_area="1";
getrequest();
for(i=0;i<request.length;i++){
if(request[i][0]=='ad_source' && request[i][1]=="3q")
{
	flag="t";
	break;
}
}
if (display=="no")
{
	if(flag == "f")
	ip_area = "1";
	else
	ip_area = "2";
}
else
{
	if(flag == "f")
	ip_area = "3";
	else
	ip_area = "2";
}

/////////////////////广告内容: 1,北京非QQ 2,北京和外地QQ 3,外地非QQ/////////////////////////////////////////
//列表页右侧1

function fRight(){
var o={};
switch(ip_area)
{
    case "3":
        //o.middle=GetFlash("http://news.2hua.com/adiframe/ggimgs/index/index_top.swf","960","80",2);
          o.middle=GetFlash("http://news.2hua.com/adiframe/ggimgs/news/right_1.swf","310","225",2);  
        break;
    case "2":
        //o.middle=GetFlash("http://news.2hua.com/adiframe/ggimgs/index/index_top.swf","960","80",2);
          o.middle=GetFlash("http://news.2hua.com/adiframe/ggimgs/news/right_1.swf","310","225",2);     
        break;
    default:
        //o.middle=GetFlash("http://news.2hua.com/adiframe/ggimgs/index/index_top.swf","960","80",2);
         o.middle=GetFlash("http://news.2hua.com/adiframe/ggimgs/news/right_1.swf","310","225",2);  
}

return o;
}

//头部广告位
function fIndexTop(){
var o={};
switch(ip_area)
{
    case "3":
        //o.middle='<embed src="http://news.2hua.com/adiframe/ggimgs/index/index_top.swf" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash  type=application/x-shockwave-flash" width="960" height="80" wmode="opaque"></embed>';
        o.middle=GetFlash("http://news.2hua.com/adiframe/ggimgs/index/index_top.swf","960","80",2);
        break;
    case "2":
        //o.middle='<embed src="http://news.2hua.com/adiframe/ggimgs/index/index_top.swf" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash  type=application/x-shockwave-flash" width="960" height="80" wmode="opaque"></embed>';
        o.middle=GetFlash("http://news.2hua.com/adiframe/ggimgs/index/index_top.swf","960","80",2);
        break;
    default:
        //o.middle='<embed src="http://news.2hua.com/adiframe/ggimgs/index/index_top.swf" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash  type=application/x-shockwave-flash" width="960" height="80" wmode="opaque"></embed>';
        o.middle=GetFlash("http://news.2hua.com/adiframe/ggimgs/index/index_top.swf","960","80",2);
}

return o;
}

//列表页右侧2
function fRight2(){
var o={};
switch(ip_area)
{
    case "3":
        o.middle='<a href="http://kafei.3230.com?from=2hua51" target=_blank><img src="http://news.2hua.com/adiframe/ggimgs/news/kf.gif" width="310" height="130" align="top" /></a>';
        break;
    case "2":
 o.middle='<a href="http://kafei.3230.com?from=2hua51" target=_blank><img src="http://news.2hua.com/adiframe/ggimgs/news/kf.gif" width="310" height="130" align="top" /></a>';
        break;
    default:
 o.middle='<a href="http://kafei.3230.com?from=2hua51" target=_blank><img src="http://news.2hua.com/adiframe/ggimgs/news/kf.gif" width="310" height="130" align="top" /></a>';  
}

return o;
}

////////////////////////////////函数部份///////////////////////////////////////

// 页面输出策略配置
function fPageWrite(s){
	try{
		if(typeof s == "function"){
			s = s();
		}
		if (s)
		{		
		    if(s==""){
		        s="文件载入中,请稍候...";		
		    }
			document.write(s);
			//return s;
		}
	}catch(e){}
}
// 页面输出策略配置
function fPageWrite2(s){
	try{
		if(typeof s == "function"){
			s = s();
		}
		if (s)
		{		
		    if(s==""){
		        s="文件载入中,请稍候...";		
		    }
			//document.write(s);
			return s;
		}
	}catch(e){}
}

//flash mode
function GetFlash(path,width,height,type)
{
    var value = "";
    switch(type)
    {
        case 1:
            value = "<embed src=\""+path+"\" quality=\"high\" pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash  type=application/x-shockwave-flash\" width=\""+width+"\" height=\""+height+"\" wmode=\"opaque\"></embed>";
            break;
        case 2:
            value = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" width=\""+width+"\" height=\""+height+"\">\r\n";
            value = value + "  <param name=\"movie\" value=\""+path+"\" />\r\n";
            value = value + "  <param name=\"quality\" value=\"high\" />\r\n";
            value = value + "  <embed src=\""+path+"\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\""+width+"\" height=\""+height+"\"></embed>\r\n";
            value = value + "</object>\r\n";
            break;
			//右空7px
        case 3:
            value = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" width=\""+width+"\" height=\""+height+"\" style=\"margin-right: 7px;\">\r\n";
            value = value + "  <param name=\"movie\" value=\""+path+"\" />\r\n";
            value = value + "  <param name=\"quality\" value=\"high\" />\r\n";
            value = value + "  <embed src=\""+path+"\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\""+width+"\" height=\""+height+"\"></embed>\r\n";
            value = value + "</object>\r\n";
            break;			
        //不显示flash
        case 4:
            value = "";
            break;
        //其它
        default:
            value = "文件加载失败...";                
    }
    return value;
}

//载入广告
function insertad(id,value,height)
{
    if (document.getElementById(id).innerHTML == "" || document.getElementById(id).innerHTML == "文件载入中,请稍候...")
    {
		if (height !="")
		{
			document.getElementById(id).style.paddingTop = height;
			document.getElementById(id).style.paddingBottom = height;
		}
        document.getElementById(id).innerHTML = value;
    }
    else
    {
		if (height !="")
		{
			document.getElementById(id).style.paddingTop = height;
			document.getElementById(id).style.paddingBottom = height;
		}
        document.getElementById(id).innerHTML = value;
        //document.getElementById(id).innerHTML = document.getElementById(id).innerHTML + value;
    }
}
//隐藏广告
function hiddenad(id,value,height)
{
    if (document.getElementById(id) != null)
    {
		document.getElementById(id).innerHTML = "";
		if (height !="")
		{
			document.getElementById(id).style.height = height;
		}
		else
		{
			document.getElementById(id).style.display = "none";
		}
    }
}

//载入函数 list
function play_list_ad()
{	
	var t=fIndexTop();
    insertad("fIndexTop",fPageWrite2(t.middle),"10px");
    //cnzz
    var t=web_pv_counter();
    insertad("pv_counter",fPageWrite(t.middle),"");
}
//载入函数 list_r
function play_list_r_ad()
{
    var t=fRight();
    insertad("fRight",fPageWrite2(t.middle),"");
    var t=fRight2();
    insertad("fRight2",fPageWrite2(t.middle),"");
}


//temp

function play_other_ad2()
{
	
	    var t=fIndexTop();
    insertad("fIndexTop",fPageWrite2(t.middle),"10px");

}

function play_beauty_ad()
{
    var t=fRight();
    insertad("fRight",fPageWrite2(t.middle),"");
   var t=fRight2();
    insertad("fRight2",fPageWrite2(t.middle),"");
}
